import { createRouter, createWebHashHistory } from 'vue-router'
import Login from '@/views/login/Login.vue'
import Layout from '@/views/layout/Layout.vue'

const routes = [
  {
    path: '/',
    redirect: '/login'
  },
  {
    path: '/login',
    component: Login
  },
  {
    path: '/layout',
    component: Layout,
    redirect: '/layout/home',
    children: [
      {
        path: '/layout/home', 
        meta: { title: '主页' },
        component: () => import('@/views/layout/child/Home.vue')
      },
      {
        path: '/layout/shopInfo', 
        meta: { title: '店铺管理' },
        component: () => import('@/views/layout/child/ShopInfo.vue')
      },
      {
        path: '/layout/orderList', 
        meta: { title: '订单管理' },
        component: () => import('@/views/layout/child/OrderList.vue')
      },

      {
        path:'/layout/account',
        meta: { title: '账号管理' },
        redirect: '/layout/accountList',
        component: () => import('@/views/layout/child/account/Account.vue'),
        children: [
          {
            path: '/layout/accountAdd',
            meta: { title: '添加账号' },
            component: () => import('@/views/layout/child/account/child/AccountAdd.vue')
          },
          {
            path: '/layout/accountList', 
            meta: { title: '账号列表' },
            component: () => import('@/views/layout/child/account/child/AccountList.vue')
          },
          {
            path: '/layout/accountEdit',
            meta: { title: '修改密码' },
            component: () => import('@/views/layout/child/account/child/AccountEdit.vue')
          },
          {
            path: '/layout/accountCenter', 
            meta: { title: '个人中心' },
            component: () => import('@/views/layout/child/account/child/AccountCenter.vue')
          },
        ]
      },

      {
        path: '/layout/goods',
        meta: { title: '商品管理' },
        redirect: '/layout/goodsList',
        component: () => import('@/views/layout/child/goods/Goods.vue'),
        children: [
          {
            path: '/layout/goodsAdd', 
            meta: { title: '商品添加' },
            component: () => import('@/views/layout/child/goods/child/GoodsAdd.vue')
          },
          {
            path: '/layout/goodsList', 
            meta: { title: '商品列表' },
            component: () => import('@/views/layout/child/goods/child/GoodsList.vue')
          },
          {
            path: '/layout/goodsType', 
            meta: { title: '商品分类' },
            component: () => import('@/views/layout/child/goods/child/GoodsType.vue')
          },
        ]
      },

      {
        path:'/layout/manage',
        meta: { title: '数据统计' },
        redirect: '/layout/goodsStatistics',
        component: () => import('@/views/layout/child/manage/Manage.vue'),
        children: [
          {
            path: '/layout/goodsStatistics', 
            meta: { title: '商品统计' },
            component: () => import('@/views/layout/child/manage/child/GoodsStatistics.vue')
          },
          
          {
            path: '/layout/orderStatistics', 
            meta: { title: '订单统计' },
            component: () => import('@/views/layout/child/manage/child/OrderStatistics.vue')
          },
        ]
      },

      {
        path: '/layout/permissions',
        meta: { title: '权限管理' },
        redirect: '/layout/permissionInfo',
        component: () => import('@/views/layout/child/permissions/Permissions.vue'),
        children: [
          {
            path: '/layout/permissionInfo',
            meta: { title: '权限管理' },
            component: () => import('@/views/layout/child/permissions/child/PermissionInfo.vue')
          },
          {
            path: '/layout/rolePermission', 
            meta: { title: '角色管理' },
            component: () => import('@/views/layout/child/permissions/child/RolePermission.vue')
          },
        ]
      },

    ]
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router
